<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="/callimachus/template.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:calli="http://callimachusproject.org/rdf/2009/framework#"
    xmlns:foaf="http://xmlns.com/foaf/0.1/"
    xmlns:skos="http://www.w3.org/2004/02/skos/core#"
    xmlns:vcard="http://www.w3.org/2006/vcard/ns#"
    xmlns:gr="http://purl.org/goodrelations/v1#"
    xmlns:directory="http://dir.w3.org/rdf/2012/directory/">
<head>
    <title>New Organization</title>
	<script type="text/javascript">
    // <![CDATA[
        jQuery(function($) {
            var legal = parent.document.getElementById('legal').value;
            $('#legal').val(legal);
            var orgtype = parent.document.getElementById('orgtype');
            var about = orgtype.options[orgtype.selectedIndex].getAttribute('about');
            if (about) {
                $('#orgtype').append('<span about="' + about + '" />');
            }
        });
		function updateLabel() {
			var legal = $('#legal').val();
			var unit = $('#unit').val();
            var label = legal + ' ' + unit;
            $('#label').val(label);
            $('#fn').val(label);
            $('#name').val(legal);
		}
    // ]]>
	</script>
</head>
<body>
    <h1>New Organization</h1>
	<form id="form" typeof="vcard:Organization vcard:VCard gr:BusinessEntity"
            method="POST" action="" enctype="application/rdf+xml"
            onsubmit="updateLabel();return calli.saveResourceAs(event, calli.slugify($('#unit').val()))">
		<div class="control-group">
			<label for="unit" class="control-label">Business Unit</label>
            <div class="controls">
    			<input id="unit" type="text" autofocus="autofocus" value="{vcard:organization-unit}" required="required"
                    title="The name of a unit, division, department, or group within an organization" />
    			<input id="legal" type="hidden" value="{gr:legalName}" />
            	<input id="label" type="hidden" value="{rdfs:label}" />
        		<input id="fn" type="hidden" value="{vcard:fn}" />
        		<input id="name" type="hidden" value="{vcard:organization-name}" />
                <span id="orgtype" rel="directory:isOrganizationType">
                    <span about="?orgtype" rev="calli:hasComponent" resource="type-of-organization/" />
                </span>
            </div>
		</div>

		<div class="control-group">
			<label for="url" class="control-label">Web site URL</label>
            <div class="controls">
			    <input id="url" type="url" required="required" value="{vcard:url}" style="width:52ex" />
            </div>
		</div>
		<div class="hbox">
			<div class="control-group">
				<label for="email" class="control-label">Email</label>
                <div class="controls">
				    <input id="email" type="email" value="{vcard:workEmail}" title="Preferred e-mail address for contact" />
                </div>
			</div>
			<div class="control-group">
				<label for="tel" class="control-label">Telephone</label>
                <div class="controls">
				    <input type="text" id="tel" placeholder="+country code-area-number" value="{vcard:workTel}" />
                </div>
			</div>
		</div>

        <div class="form-actions">
		    <button id="submit" type="submit" class="btn btn-primary">Create</button>
        </div>
	</form>
</body>
</html>
